/*
 * Holaf Utilities - Shared Panel Styles
 * Common styles for all floating utility panels and modals.
 */

/* Base style for floating panels */
.holaf-utility-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    min-width: 300px !important;
    min-height: 200px !important;
    width: 700px;
    height: 550px;
    max-width: 90vw !important;
    max-height: 90vh !important;
    background-color: var(--holaf-background-primary) !important;
    border: 1px solid var(--holaf-border-color) !important;
    border-radius: 8px !important;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.6) !important;
    z-index: 1001;
    display: flex;
    flex-direction: column !important;
    font-family: sans-serif !important;
    overflow: hidden !important;
    color: var(--holaf-text-primary) !important;
    /* --holaf-mm-zoom-factor and --holaf-nm-zoom-factor are set on specific panels by JS */
}

/* Header for dragging, title, and buttons */
.holaf-utility-header {
    background-color: var(--holaf-background-secondary) !important;
    color: var(--holaf-text-primary) !important;
    padding: 4px 12px !important;
    cursor: move !important;
    user-select: none !important;
    border-bottom: 1px solid var(--holaf-border-color) !important;
    border-top-left-radius: 8px !important;
    border-top-right-radius: 8px !important;
    display: flex !important;
    align-items: center !important;
    font-weight: bold !important;
    flex-shrink: 0 !important;
    gap: 8px;
}

.holaf-utility-header>span:first-of-type { /* Title span */
    flex-grow: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.holaf-utility-close-button {
    background: none !important;
    color: var(--holaf-text-secondary) !important;
    border: none !important;
    border-radius: 50% !important;
    width: 24px !important;
    height: 24px !important;
    line-height: 24px !important;
    text-align: center !important;
    cursor: pointer !important;
    font-size: 16px !important;
    font-weight: bold !important;
    transition: background-color 0.2s, color 0.2s !important;
    margin-left: auto !important;
    flex-shrink: 0;
}

.holaf-utility-close-button:hover {
    background-color: #c44 !important;
    color: white !important;
}

.holaf-utility-resize-handle {
    position: absolute !important;
    bottom: 0 !important;
    right: 0 !important;
    width: 16px !important;
    height: 16px !important;
    cursor: se-resize !important;
    background-image: linear-gradient(135deg, transparent 0%, transparent 50%, var(--holaf-text-secondary, #888) 50%, var(--holaf-text-secondary, #888) 75%, transparent 75%, transparent 100%) !important;
    z-index: 2 !important;
}

/* Shared styles for buttons in Panel Header (Theme, Fullscreen etc) */
.holaf-header-button-group {
    display: flex !important;
    gap: 4px !important;
    margin-left: 10px !important;
    align-items: center !important;
}

.holaf-header-button {
    background: var(--holaf-header-button-bg) !important;
    border: 1px solid var(--holaf-border-color) !important;
    color: var(--holaf-header-button-text) !important;
    border-radius: 4px !important;
    cursor: pointer !important;
    padding: 2px !important;
    width: 24px !important;
    height: 24px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: background-color 0.15s, color 0.15s, border-color 0.15s !important;
}

.holaf-header-button:hover {
    background: var(--holaf-header-button-hover-bg) !important;
    color: var(--holaf-header-button-hover-text) !important;
    border-color: var(--holaf-accent-color) !important;
}

/* Theme selection dropdown menu INSIDE panels */
.holaf-theme-menu {
    position: absolute !important;
    top: 100% !important;
    right: 0 !important;
    background-color: var(--holaf-background-secondary) !important;
    border: 1px solid var(--holaf-border-color) !important;
    border-radius: 4px !important;
    z-index: 1002 !important; /* Above panel content, below main dropdown */
    display: none;
    list-style: none !important;
    padding: 5px !important;
    margin: 2px 0 0 !important;
    min-width: 150px !important;
}

.holaf-theme-menu li {
    color: var(--holaf-text-secondary);
    padding: 6px 10px;
    cursor: pointer;
    border-radius: 3px;
    transition: background-color 0.15s, color 0.15s;
}

.holaf-theme-menu li:hover {
    background-color: var(--holaf-accent-color) !important;
    color: var(--holaf-button-text) !important;
}

/* Common button style for inside panels (ComfyUI like) */
.holaf-utility-panel .comfy-button {
    background-color: var(--holaf-button-background) !important;
    color: var(--holaf-button-text) !important;
    border: 1px solid transparent !important;
    padding: 6px 12px !important;
    text-align: center !important;
    text-decoration: none !important;
    display: inline-block !important;
    font-size: 14px !important;
    border-radius: 4px !important;
    cursor: pointer !important;
    transition: opacity 0.2s !important;
}

.holaf-utility-panel .comfy-button:hover {
    opacity: 0.85;
}

.holaf-utility-panel .comfy-button:active {
    opacity: 0.7;
}

.holaf-utility-panel .comfy-button:disabled {
    background-color: var(--holaf-background-secondary) !important;
    color: var(--holaf-text-secondary) !important;
    cursor: not-allowed !important;
    opacity: 0.6 !important;
}

/* Custom scrollbar for panel content areas (e.g. Model Manager list, Terminal view) */
.holaf-utility-panel ::-webkit-scrollbar {
    /* Using a general selector for content areas within panels.
       Specific panels might override this if needed.
       Model Manager & Terminal have their own due to zoom factor considerations.
       Nodes Manager & Settings Panel also have their specific scrollbar styles.
    */
    width: 10px;
}

.holaf-utility-panel ::-webkit-scrollbar-track {
    background: var(--holaf-scrollbar-track);
}

.holaf-utility-panel ::-webkit-scrollbar-thumb {
    background-color: var(--holaf-scrollbar-thumb);
    border-radius: 5px;
    border: 2px solid var(--holaf-scrollbar-track);
}

.holaf-utility-panel ::-webkit-scrollbar-thumb:hover {
    background-color: color-mix(in srgb, var(--holaf-scrollbar-thumb) 70%, var(--holaf-accent-color) 30%);
}


/* --- CUSTOM MODAL DIALOG STYLES --- */
#holaf-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 100000; /* Highest z-index */
    display: flex;
    align-items: center;
    justify-content: center;
}

#holaf-modal-dialog {
    background-color: var(--holaf-background-primary, #1E1E1E);
    color: var(--holaf-text-primary, #E0E0E0);
    border: 1px solid var(--holaf-border-color, #3F3F3F);
    border-radius: 8px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.6);
    min-width: 300px;
    max-width: 500px;
    width: auto;
    display: flex;
    flex-direction: column;
}

#holaf-modal-dialog .holaf-utility-header { /* Modal uses the same header structure */
    cursor: default !important; /* No dragging for modals */
}

#holaf-modal-dialog .holaf-modal-content {
    padding: 20px 15px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--holaf-text-secondary, #A0A0A0); /* Default content color */
}

#holaf-modal-dialog .holaf-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 10px 15px;
    border-top: 1px solid var(--holaf-border-color, #3F3F3F);
}

/* Secondary button style for modals (e.g., "Cancel") */
#holaf-modal-dialog .holaf-modal-footer .comfy-button.secondary {
    background-color: var(--holaf-background-secondary) !important;
    color: var(--holaf-text-secondary) !important;
    border: 1px solid var(--holaf-border-color) !important;
}

#holaf-modal-dialog .holaf-modal-footer .comfy-button.secondary:hover {
    border-color: var(--holaf-accent-color) !important;
    color: var(--holaf-text-primary) !important;
    opacity: 1; /* Override default comfy-button hover opacity */
}


/* --- MODIFICATION START: Style for focused dialog button --- */
.holaf-utility-panel .comfy-button.dialog-button-focused, .holaf-dialog-item-focused.comfy-button, .holaf-dialog-item-focused label {
    outline: 2px solid var(--holaf-accent-color) !important;
    outline-offset: 2px !important;
}
/* --- MODIFICATION END --- */


/* --- Fullscreen Panel Style --- */
/* Applied to any .holaf-utility-panel that also gets .holaf-panel-fullscreen */
.holaf-panel-fullscreen {
    top: 30px !important; /* Adjust for ComfyUI's top menu bar (30px is a more reliable value) */
    left: 0 !important;
    width: 100vw !important;
    height: calc(100vh - 30px) !important;
    max-width: 100vw !important;
    max-height: calc(100vh - 30px) !important;
    transform: none !important;
    border-radius: 0 !important;
    transition: all 0.2s ease-in-out;
}

.holaf-panel-fullscreen .holaf-utility-resize-handle {
    display: none !important; /* No resize handle in fullscreen */
}

.holaf-panel-fullscreen .holaf-utility-header {
    border-top-left-radius: 0 !important;
    border-top-right-radius: 0 !important;
}